package gridmath;

import pac.SearchDatastructure;
import preprocessing.WindowingSystem;
import datastructures.UserParameters;

public class NonemptyCoordinatesCalculator extends CaseMatrixBase {
	
	private SearchDatastructure searcher;

	public NonemptyCoordinatesCalculator (UserParameters userparams, WindowingSystem windowmaker, SearchDatastructure I) {
		super (windowmaker, userparams.getMaxorder());
		searcher = I;
		
		specialTypeOfOperation = MatrixOperations.calculateNonZeroCoordinates;
	}
	
	public double doOperation (double operand) {
		switch (currentDimension) {		
			case 1:
				if( searcher.windowMaker.counter[i] == 0) 
					return 0;
				else 
					return 1;
				
			case 2:
				if( searcher.windowMaker.counter[i] == 0 || searcher.windowMaker.counter[j] == 0) 
					return 0;
				else 
					return 1;
				
			case 3:
				if ( searcher.windowMaker.counter[i] == 0 || searcher.windowMaker.counter[j] == 0 || searcher.windowMaker.counter[k] == 0) 
					return 0;
				else 
					return 1;
				
			default:
				if( searcher.windowMaker.counter[i]  == 0 || searcher.windowMaker.counter[j] == 0 || searcher.windowMaker.counter[k] == 0 || searcher.windowMaker.counter[m] == 0) 
					return 0;
				else 
					return 1;			
				
		}
		
	}
	
}
